package com.aurora.app.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.aurora.app.dao.HelpImageDao;
import com.aurora.app.dao.ThingImageDao;
import com.aurora.app.entity.HelpImage;
import com.aurora.app.entity.ThingImage;
import com.aurora.app.enums.FakeDelete;
import com.aurora.base.dao.BaseDao;
import com.aurora.base.dto.Order;
import com.aurora.base.service.BaseService;

@Service
public class HelpImageService extends BaseService<HelpImage> {

	@Resource
	private HelpImageDao baseDao;
	@Override
	public BaseDao<HelpImage> getBaseDao() {
		// TODO Auto-generated method stub
		return this.baseDao;
	}
	
	/**
	 * 获取最新thing最新创建的那一福图片
	 * @param thingId
	 * @return
	 */
	public HelpImage  getFirstImageByHelpId(String helpId){
		Order order = new Order();
		order.put("createTime", Order.DESC);
		List<HelpImage> imgList =this.baseDao.list(order,0,1,"o.isDelete = ? and o.help.id =? ", FakeDelete.NODELETE,helpId);
		if(imgList!=null&!imgList.isEmpty()){
			return imgList.get(0);
		}
		return null;
	}
	
	public List<HelpImage> getListByHelpId(String helpId){
		return this.baseDao.list("o.isDelete = 0 and o.help.id = ?", helpId);
	}

}
